<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>欢迎回来</title>
</head>
<body>
	<div id="box2">
		<h1 id="text"></h1>
		<button id="tc">退出当前账号</button>
	</div>
	<script>
		//退出登陆
		
		var str = document.cookie;
		var index = str.split(';');
		var shuju = index[0].substring(9);
		//字符串截取
		text.innerHTML = '欢迎回来   '+shuju;
		tc.onclick = function(){
			var date = new Date();
			//当前时间减去有效期换成毫秒
			var expReadyDay = 1;

			date.setTime(date.getTime()-expReadyDay*24*60*60*1000);
			document.cookie = index[0] + ';expires=' + date.toUTCString();
			document.cookie = index[1] + ';expires=' + date.toUTCString();
			window.location.href = 'index.html';
			console.log(document.cookie);
		}
	</script>
</body>
</html>